package com.lancoo.ccas53.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lancoo.ccas53.entity.Schedule;
import com.lancoo.ccas53.entity.ScheduleConflictInfo;
import com.lancoo.ccas53.entity.ScheduleSelect;
import com.lancoo.ccas53.entity.TeachingClass;
import com.lancoo.ccas53.pojo.common.PageInfo;
import com.lancoo.ccas53.pojo.dto.*;
import com.lancoo.ccas53.pojo.vo.*;

import javax.servlet.http.HttpServletResponse;
import java.util.HashSet;
import java.util.List;

/**
 * <p>
 * 课表 服务类
 * </p>
 *
 * @author quin.song
 * @since 2024-05-20
 */
public interface ScheduleService extends IService<Schedule> {


    /**
     * 获取教学班数据.未锁定教学班。 教务管理员学院传null,专业性质传1. 院系管理员学院传学院id，专业性质传2
     *
     * @param taskId
     * @param campusId  校区id 传null获取全部
     * @param collegeId 学院id 传null获取全部
     * @param majorProp 专业性质，1:公共课，2:专业课
     * @return
     */
    List<ArrangeTeachingClassDto> getTeachingClassDate(Integer taskId, String campusId, String collegeId, Integer majorProp);


    List<ArrangeRoomDto> getArrangeRoom(Integer taskId, String schoolId, String termId, String campusId);

    /**
     * 获取学时学时信息 （过滤掉时间禁排的学时）
     *
     * @param schoolId
     * @param term
     * @param collegeId
     * @return
     */
    List<ArrangePeriod> getArrangeTimeCode(Integer taskId, String schoolId, String term, String collegeId);

    List<ArrangePeriod> getArrangeTimeCodeV2(Integer taskId, String schoolId, String term, String collegeId);

    List<ArrangeRoomRuleDto> getArrangeRoomProhibit(Integer taskId, String schoolId, String termId, String campusId, String collegeId);

    List<ArrangeTeacherRuleDto> getArrangeTeacherTime(Integer taskId, String collegeId);

    List<ArrangeCourseRuleDto> getArrangeCourseProhibit(Integer taskId, String collegeId);

    /**
     * 获取本任务已经锁定的课表。以及本学期其他任务课表  包含教学班的教室id、学时信息
     *
     * @param taskId
     * @param campusId
     * @param isLocked             1未锁定  2锁定 null全部
     * @param majorProp            课程类型 用于区分排课类型 传null表示仅教务管理员排课，获取锁定课表
     * @param collegeId            null全部 空字符串公共课 其他表示该院系专业课
     * @param teachingClassDtoList
     * @return
     */
    List<ArrangeScheduleDto> getLockSchedule(Integer taskId, String campusId, Integer isLocked, Integer majorProp, String collegeId, List<ArrangeTeachingClassDto> teachingClassDtoList);

    /**
     * 存储每轮排课的课程信息，即课表信息
     *
     * @param schedules
     * @param collegeId 指定学院 传null删除全部
     * @param majorProp 课程类型 用于区分排课类型 传null表示仅教务管理员排课，删除课表全部数据
     */
    void addBathSchedule(Integer taskId, List<Schedule> schedules, String collegeId, Integer majorProp);

    /**
     * 存储每轮排课的冲突信息
     *
     * @param scheduleConflicts
     */
    void addBatchScheduleConflict(Integer taskId, List<ScheduleConflictInfo> scheduleConflicts, List<Long> roomIds);

    /**
     * 更新教学班排课状态
     *
     * @param arrangeTeachingClassUpdates
     */
    void updateScheduleState(List<ArrangeTeachingClassUpdate> arrangeTeachingClassUpdates);

    Boolean allToTeachingClassUnit(Integer taskId, String baseCollegeId);

     List<Schedule> generateTeachingClassUnit(Integer taskId, List<GenerateTeachingClassUnitInput> generateTeachingClassUnits);

    OwnerTeachingClassTree teachingClassTreeOwner(Integer taskId, String baseCollegeId, String keyword);

    List<CollegeTeachingClassTree> teachingClassTreeSchool(Integer taskId, String keyword);


    List<Object> autoArrangement(Integer taskId, String collegeId, Integer majorProp);

    List<TeachingClassWeekScheduleDto> getTeachingClassSchedule(Integer taskId, List<Long> teachingClassIds);

    List<TeachingClassWeekScheduleDto> getTeachingClassAndSchedule(Integer taskId, List<Long> teachingClassIds);

    String getTeachingClassAndScheduleByType(Integer taskId, Long teachingClassId, Integer hourType, String preGroup);

    void fillConflict(List<ScheduleConflictInfo> cnoflictList);

    List<TeachingClassWeekScheduleDto> getGroupTeachingClassAndSchedule(Integer taskId, String uniqueGroupSign, String groupName);

    void teacherScheduleToExcel(HttpServletResponse response, Integer taskId, Long teacherId, String baseCollegeName);

    PageInfo<VenueSessionVo> getVenueSession(Integer currentPage, Integer pageSize, Integer taskId, String weeks, String timeCodes, Integer campusId, Integer buildingId, Integer selectRoomType, Long roomId, String keyword, ArrangeTeachingClassDto teachingClass, Integer departId, Integer conflictCheck, Integer capacityCheck, String collegeId, int outer);

    PageInfo<VenueSessionVo> getVenueSessionSelect(Integer currentPage, Integer pageSize, Integer taskId, String weeks, String timeCodes, Integer campusId, Integer buildingId, Long roomId, String keyword, ArrangeTeachingClassDto teachingClass, Integer departId, Integer conflictCheck, Integer capacityCheck, String collegeId);

    HashSet<String> getGroupVenueSession(Integer currentPage, Integer pageSize, Integer taskId, String weeks, String timeCodes, Integer campusId, Integer buildingId, Long roomId, String keyword, List<ArrangeTeachingClassDto> teachingClassList, Integer departId, Integer conflictCheck, Integer capacityCheck, String collegeId);

    List<ScheduleDto> updateVenueSession(List<Schedule> startSchedule, List<Schedule> stopSchedule, Long teachingClassId, Integer hourType);

    List<ScheduleSelectGroup> updateVenueSessionSelect(List<ScheduleSelect> startSchedule, List<ScheduleSelect> stopSchedule, String teachingClassId, Integer hourType);

    void removeSchedule(Integer taskId, List<Schedule> scheduleList);

    List<TeachingClassWeekScheduleDto> getTeacherUnRange(Integer taskId, String collegeId, Long teacherId, String keyword);

    List<TeachingClassWeekScheduleDto> getRoomUnRange(Integer taskId, String collegeId, Long roomId, String keyword);

    List<TeachingClassWeekScheduleDto> getTeacherSchedule(Integer taskId, Long teacherId, String timeCodes);

    List<TeachingClassWeekScheduleDto> getRoomSchedule(Integer taskId, Long roomId, String timeCodes);

    List<StudentCollegeTree> getStudentTree(Integer taskId, String keyword);

    List<TeachingClassWeekScheduleDto> getStudentSchedule(Integer taskId, Long studentId);

    List<StudentCollegeTree> getClassTree(Integer taskId, String keyword);

    List<TeachingClassWeekScheduleDto> getClassSchedule(Integer taskId, String classId);

    List<RoomVo> getRoomTree(Integer taskId, String schoolId, String term, String baseCollegeId, Integer module, String keyword);

    PageInfo<AllScheduleVo> getAllTeacherSchedule(Integer taskId, String schoolId, String keyword, String term, String collegeId, Integer currentPage, Integer pageSize);

    PageInfo<AllScheduleVo> getAllRoomSchedule(Integer taskId, String schoolId, String term, Integer campusId, Integer buildingId, String keyword, Integer currentPage, Integer pageSize);

    PageInfo<AllScheduleVo> getAllStudentSchedule(Integer taskId, String schoolId, String term, String gradeId, String classId, String keyword, String collegeId, Integer currentPage, Integer pageSize);

    PageInfo<TeachingClassSegmentVo> getTeachingClassSegmentPage(Integer taskId, Page<TeachingClassSegmentVo> page, String gradeId, String majorId, String type, String keyword, String baseCollegeId);

    List<ViewScheduleDto> getUnRangeSchedule(Integer taskId, Long teachingClassId);

    List<GroupViewSchedule> getGroupUnRangeSchedule(Integer taskId, String subId, String subName);

    List<ViewScheduleDto> getTeacherUnRangeSchedule(Integer taskId, Long teacherId, Long teachingClassId);

    List<ViewScheduleDto> getRoomUnRangeSchedule(Integer taskId, Long roomId, Long teachingClassId);


    String allScheduleToExcel(Integer taskId, Integer type);

    void exportedVenueSchedule(HttpServletResponse response, Integer taskId, Long roomId);

    void summaryScheduleToExcel(HttpServletResponse response, Integer taskId, Integer scheduleType);

    void segmentToExcel(HttpServletResponse response, Integer taskId, String gradeId, String collegeId, String keyword);

    void lockAll(Integer taskId, String baseCollegeId);

    void lockUnLockAll(Integer taskId, Integer lock, Integer arrangeRound);

    List<TeachingClass> lockRound(Integer taskId);

    Integer isLockedNormal(Integer taskId, String collegeId);

    void allNormalLocal(Integer taskId, String collegeId, Integer lock);

    void synchronizeUpdate(Integer taskId);

    void exportStudentSchedule(HttpServletResponse response, Integer taskId, Long student);

    List<ArrangeTeachingClassDto> getSubTeachingClassList(List<String> subIds);

    List<ScheduleSelectGroup> generateTeachingClassUnitSelect(Integer taskId, GenerateTeachingClassUnitInputSelect generateTeachingClassUnit);

    void removeTeachingClassScheduleSelect(Integer taskId, List<String> teachingClassIds);

    void teacherBatch(HttpServletResponse response, Integer taskId, String collegeId);

    void exportRoomBatch(HttpServletResponse response, Integer taskId, String buildingId);

    String teacherScheduleToExcel1(Integer taskId, Long teacherId, String baseCollegeName);

    String exportedVenueSchedule1(Integer taskId, Long o);

    void exportClassSchedule(HttpServletResponse response, Integer taskId, String classId);

    void exportTimeSlotRoom(Integer taskId, String schoolId, String term, HttpServletResponse response);

    void exportClassScheduleV2(HttpServletResponse response, Integer taskId, Long student);

    void exportClassScheduleBatch(HttpServletResponse response, Integer taskId, String gradeId);

    String exportClassSchedule1(Integer taskId, String o);

    boolean updateWeek(Integer taskId, List<Long> ids, String week);

    boolean subSchedule(Integer taskId, List<Long> ids);
}
